using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.IO;

namespace IETTsor
{
    public class HatlarHelper
    {
        public static List<string> LoadHatlar()
        {
            System.Collections.Generic.List<string> hatlar = new System.Collections.Generic.List<string>();
            Directory.SetCurrentDirectory(HttpContext.Current.Server.MapPath("."));

            // Code that runs on application startup
            if (Directory.Exists("data"))
                try
                {
                    hatlar = new System.Collections.Generic.List<string>(System.IO.Directory.GetFiles("data", "*.xml"));
                    for (int i = 0; i < hatlar.Count; i++)
                        hatlar[i] = hatlar[i].ToLower();
                }
                catch (Exception ex)
                {
                    throw new Exception("IO error. Cannot list directory contents.", ex);
                }
            else
            {
                //Response.Write("-Invalid configuration.-");
                throw new Exception("Data directory does no exist.");
            }

            return hatlar;
        }
    }
}
